<?php

/**
 * Job form base class.
 *
 * @method Job getObject() Returns the current form's model object
 *
 * @package    maximous
 * @subpackage form
 * @author     Mina.Gerges.Wadea
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseJobForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                  => new sfWidgetFormInputHidden(),
      'category_id'         => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Category'), 'add_empty' => false)),
      'company_id'          => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Company'), 'add_empty' => true)),
      'user_id'             => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('User'), 'add_empty' => true)),
      'title'               => new sfWidgetFormInputText(),
      'description'         => new sfWidgetFormInputText(),
      'contact_information' => new sfWidgetFormInputText(),
      'visits'              => new sfWidgetFormInputText(),
      'need_check'          => new sfWidgetFormInputCheckbox(),
      'statues'             => new sfWidgetFormChoice(array('choices' => array(1 => 1, 2 => 2, 3 => 3))),
      'created_at'          => new sfWidgetFormDateTime(),
      'updated_at'          => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'                  => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'category_id'         => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Category'))),
      'company_id'          => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Company'), 'required' => false)),
      'user_id'             => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('User'), 'required' => false)),
      'title'               => new sfValidatorString(array('max_length' => 255)),
      'description'         => new sfValidatorPass(),
      'contact_information' => new sfValidatorString(array('max_length' => 255)),
      'visits'              => new sfValidatorInteger(array('required' => false)),
      'need_check'          => new sfValidatorBoolean(array('required' => false)),
      'statues'             => new sfValidatorChoice(array('choices' => array(0 => 1, 1 => 2, 2 => 3))),
      'created_at'          => new sfValidatorDateTime(),
      'updated_at'          => new sfValidatorDateTime(),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'Job', 'column' => array('title')))
    );

    $this->widgetSchema->setNameFormat('job[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Job';
  }

}
